import request from '@/utils/request'
// import qs from 'qs'

// NAT64

// 获取列表
export function getNat64Array (params) {
  var data = fromData(params)
  return request({
    url: 'nat64/getNat64Array',
    method: 'post',
    data
  })
}

// 添加信息
export function addInfo (params) {
  var data = fromData(params)
  return request({
    url: 'nat64/addInfo',
    method: 'post',
    data
  })
}

// 删除信息
export function delInfo (params) {
  var data = fromData(params)
  return request({
    url: 'nat64/del_info',
    method: 'post',
    data
  })
}

// 编辑
export function editInfo (params) {
  var data = fromData(params)
  return request({
    url: 'nat64/editInfo',
    method: 'post',
    data
  })
}

// 获取信息
export function getInfo (params) {
  var data = fromData(params)
  return request({
    url: 'nat64/getInfo',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
